'##############
'Cockpit-Script
'##############

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhдngenden Funktionen

'(c) 23.10.2009 Rьdiger Hьlsmann
'(c) 15.04.2010 Marcel Kuhnt

'Script Version: 1.0
'Omsi release: 1.0

'Needs:
'- antrieb
'- engine
'- bremse
'- lights
'- wiper?
'- doors


'Revision History:
'- Rьdiger Hьlsmann	09.06.2009	Last Change				
'- Marcel Kuhnt		13.06.2009	Added Gearbox switches			
'- Marcel Kuhnt		13.06.2009	Moved some switchvars to other scripts	
'- Rьdiger Hьlsmann	19.06.2009	Added Openable Window Triggers
'- Rьdiger Hьlsmann	23.10.2009	Added Battery and kinderwagen light
'- Marcel Kuhnt		26.10.2009	Radio switchable with Motorkьhlung (replaced with cassette player)
'- Rьdiger Hьlsmann	28.10.2009	Added driver door
'- Rьdiger Hьlsmann	16.12.2009	Added driver curtain
'- Rьdiger Hьlsmann	18.12.2009	Bugfix driver curtain
'- Marcel Kuhnt		15.04.2010	Traegheit debugged
'- Rьdiger Hьlsmann	13.05.2010	Engine temperature
'- Rьdiger Hьlsmann	03.06.2010	Automatic battery switch on key insertion (For standard-II-buses)
'- Rьdiger Hьlsmann	08.06.2010	Automatic battery switch made optional, Auxiliary heating switchable by button or switch
'- Rьdiger Hьlsmann	23.06.2010	Added mouse-clickable wiper lever on wheel console
'- Rьdiger Hьlsmann	08.07.2010	Wiper lever: Improved usability 
'- Rьdiger Hьlsmann	18.07.2010	Wiper lever: soundfix for keyboard operation and new ignition key algorithm 
'- Rьdiger Hьlsmann	16.09.2010	Auxheat Switch Bugfix
'- Rьdiger Hьlsmann	18.09.2010	Imported microphone switch
'- Rьdiger Hьlsmann	17.10.2010	Added pressure warning needle
'- Rьdiger Hьlsmann	23.10.2010	Added old-style gear button functionality
'- Rьdiger Hьlsmann	06.11.2010	Gear-button "1" functionality removed for old-style gear buttons
'- Rьdiger Hьlsmann	16.11.2010	Heating sliders
'- Rьdiger Hьlsmann	23.11.2010	Central lubrication, cabin heater sound
'- Rьdiger Hьlsmann	23.12.2010	Included 10 "multi-purpose" dummy switches
'- Rьdiger Hьlsmann	29.12.2010	ASR switch
'- Rьdiger Hьlsmann	04.01.2011	"D-only" gear selector function
'- Rьdiger Hьlsmann	05.01.2011	fog lamp switch, high beam lever animation, clock debugged
'- Rьdiger Hьlsmann	07.01.2011	Wiper lever sound and function debugges, availybility of several cockpit functions depending on bus type (via constfile)
'- Rьdiger Hьlsmann	16.01.2011	Support for wiper turn-switch
'- Rьdiger Hьlsmann	18.01.2011	Old-style gear button sounds
'- Rьdiger Hьlsmann	26.01.2011	Invertable driver door
'- Rьdiger Hьlsmann	26.01.2011	Thermometer

'------------------------------------------------------------------------------------------


'----------------------
'	Trigger
'----------------------
'	Реверс
{trigger:automatic_R}
'	Antirepeat
	(L.L.cp_bt_gang) !
	{if}
		1 (S.L.cp_bt_gang)
	{else}
		2 (S.L.cp_bt_gang)
	{endif}
	
	
	(L.L.antrieb_getr_gangvorwahl) 1 <= 
	(L.L.cockpit_gang1) ! (L.L.cockpit_gang2) ! (L.L.cockpit_gang3) ! (L.L.cockpit_gangD) ! && && && &&
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		0 (S.L.cockpit_gangN)
		1 (S.L.cockpit_gangR)
		(L.L.Velocity) abs 5 <
		{if}
			(L.L.Velocity) abs 1 < (L.L.Brake) &&
			(L.L.cp_bt_gang) 2 < &&
			{if}
				0 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{else}
			(L.L.cp_bt_gang) 2 <
			{if}
				0 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
	{endif}
{end}

{trigger:automatic_R_off}
	(L.L.cockpit_gangR) 1 =
	{if}
		0.7 (S.L.cockpit_gangR)
	{endif}
{end}


'	Нейтралка

{trigger:automatic_N}
	(L.L.antrieb_getr_gangvorwahl) 1 = !
	{if}
		(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
	{endif}
	(T.L.ev_gangwahltaster_N)
	1 (S.L.antrieb_getr_gangvorwahl) (S.L.cockpit_gangN)
	0 (S.L.cockpit_gangR) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3) (S.L.cockpit_gangD)
	0 (S.L.cp_bt_gang) (S.L.cp_bt_gang1) (S.L.cp_bt_gang2) (S.L.cp_bt_gang3) (S.L.cp_bt_gangD)
{end}


{trigger:automatic_N_off}
	(L.L.cockpit_gangN) 1 =
	{if}
		0.7 (S.L.cockpit_gangN)
	{endif}	
{end}

'	1я передача онли

{trigger:automatic_1}
'	Antirepeat
	(L.L.cp_bt_gang1) !
	{if}
		1 (S.L.cp_bt_gang1)
	{else}
		2 (S.L.cp_bt_gang1)
	{endif}
	
	
	(L.L.antrieb_getr_gangvorwahl) 0 > (C.L.cockpit_gear_D_only) ! &&
	(L.L.cockpit_gangR) !
	{if}
		(L.L.antrieb_getr_gangvorwahl) 2 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		1 (S.L.cockpit_gang1)
		0 (S.L.cockpit_gangN) (S.L.cockpit_gang2) (S.L.cockpit_gang3) (S.L.cockpit_gangD)
		0 (S.L.cp_bt_gang2) (S.L.cp_bt_gang3) (S.L.cp_bt_gangD)
		
		(L.L.Velocity) 5 <
		{if}
			(L.L.Velocity) 1 < (L.L.Brake) &&
			(L.L.cp_bt_gang1) 2 < &&
			{if}
				2 (S.L.antrieb_getr_gangvorwahl)
			{else}
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{else}
			(L.L.cp_bt_gang1) 2 <
			{if}
				2 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
	{endif}

{end}


{trigger:automatic_1_off}
	(L.L.cockpit_gang1) 1 =
	{if}
		0.7 (S.L.cockpit_gang1)
	{endif}
{end}

'	2я передача онли

{trigger:automatic_2}
'	Antirepeat
	(L.L.cp_bt_gang2) !
	{if}
		1 (S.L.cp_bt_gang2)
	{else}
		2 (S.L.cp_bt_gang2)
	{endif}
	
	
	(L.L.antrieb_getr_gangvorwahl) 0 > (C.L.cockpit_gear_D_only) ! &&
	(L.L.cockpit_gangR) !
	{if}
		(L.L.antrieb_getr_gangvorwahl) 3 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		1 (S.L.cockpit_gang2)
		0 (S.L.cockpit_gangN) (S.L.cockpit_gang1) (S.L.cockpit_gang3) (S.L.cockpit_gangD)
		0 (S.L.cp_bt_gang1) (S.L.cp_bt_gang3) (S.L.cp_bt_gangD)
		(L.L.Velocity) 5 <
		{if}
			(L.L.Velocity) 1 < (L.L.Brake) &&
			(L.L.cp_bt_gang2) 2 < &&
			{if}
				3 (S.L.antrieb_getr_gangvorwahl)
			{else}
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{else}
			(L.L.cp_bt_gang2) 2 <
			{if}
				3 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
	{endif}
{end}

{trigger:automatic_2_off}
	(L.L.cockpit_gang2) 1 =
	{if}
		0.7 (S.L.cockpit_gang2)
	{endif}
{end}

'	3я передача онли

{trigger:automatic_3}
'	Antirepeat
	(L.L.cp_bt_gang3) !
	{if}
		1 (S.L.cp_bt_gang3)
	{else}
		2 (S.L.cp_bt_gang3)
	{endif}
	
	
	(L.L.antrieb_getr_gangvorwahl) 0 > (C.L.cockpit_gear_D_only) ! &&
	(L.L.cockpit_gangR) !
	{if}
		(L.L.antrieb_getr_gangvorwahl) 4 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		1 (S.L.cockpit_gang3)
		0 (S.L.cockpit_gangN) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gangD)
		0 (S.L.cp_bt_gang1) (S.L.cp_bt_gang2) (S.L.cp_bt_gangD)
		(L.L.Velocity) 5 <
		{if}
			(L.L.Velocity) 1 < (L.L.Brake) &&
			(L.L.cp_bt_gang3) 2 < &&
			{if}
				4 (S.L.antrieb_getr_gangvorwahl)
			{else}
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{else}
			(L.L.cp_bt_gang3) 2 <
			{if}
				4 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
	{endif}
{end}


{trigger:automatic_3_off}
	(L.L.cockpit_gang3) 1 =
	{if}
		0.7 (S.L.cockpit_gang3)
	{endif}
{end}

'	D

{trigger:automatic_D}
'	Antirepeat
	(L.L.cp_bt_gangD) !
	{if}
		1 (S.L.cp_bt_gangD)
	{else}
		2 (S.L.cp_bt_gangD)
	{endif}
	
	
	(L.L.antrieb_getr_gangvorwahl) 0 >
	(L.L.cockpit_gangR) !
	{if}
		(L.L.antrieb_getr_gangvorwahl) 7 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		1 (S.L.cockpit_gangD)
		0 (S.L.cockpit_gangN) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3)
		0 (S.L.cp_bt_gang1) (S.L.cp_bt_gang2) (S.L.cp_bt_gang3)
		(L.L.Velocity) 5 <
		{if}
			(L.L.Velocity) 1 < (L.L.Brake) &&
			(L.L.cp_bt_gangD) 2 < &&
			{if}
				7 (S.L.antrieb_getr_gangvorwahl)
			{else}
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{else}
			(L.L.cp_bt_gangD) 2 <
			{if}
				7 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
	{endif}
{end}


{trigger:automatic_D_off}
	(L.L.cockpit_gangD) 1 =
	{if}
		0.7 (S.L.cockpit_gangD)
	{endif}	
{end}


{trigger:horn}
	
		(L.L.cockpit_hupe) ! (L.L.elec_busbar_main) &&
		{if}
			(T.L.ev_hupe_an)
		{endif}
		1 (S.L.cockpit_hupe)
{end}

{trigger:horn_off}	
	
		(L.L.cockpit_hupe) (L.L.elec_busbar_main) &&
		{if}
			(T.L.ev_hupe_aus)
		{endif}
		0 (S.L.cockpit_hupe)	
	
{end}

{trigger:cp_retarder_direkt_toggle}
	(L.L.cp_retarder_sw_direkt) ! (S.L.cp_retarder_sw_direkt) s1
	(M.L.kippschaltersound)
{end}


{trigger:cp_retarder_toggle}
	(C.L.cockpit_has_retarderswitch)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_motorkuehlung_toggle}
	(C.L.cockpit_has_coolingswitch)
	{if}
		(L.L.cp_motorkuehlung_sw) ! (S.L.cp_motorkuehlung_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}


'---------------------------------------
{trigger:cp_fahrerlicht_toggle}
	(L.L.bt_cp_light) ! (S.L.bt_cp_light) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_licht_untenrechts_toggle}
	(L.L.bt_salon1_light) 
	{if}
		0 (S.L.bt_salon1_light) s1
	{else}
		1 (S.L.bt_salon1_light) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

{trigger:cp_licht_oberdeck_toggle}
	(L.L.bt_salon2_light) 
	{if}
		0 (S.L.bt_salon2_light) s1
	{else}
		1 (S.L.bt_salon2_light) s1
	{endif}		
	(M.L.kippschaltersound)
{end}



{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_unterdeck_sw) 
	{if}
		0 (S.L.cp_licht_unterdeck_sw) s1
	{else}
		1 (S.L.cp_licht_unterdeck_sw) s1
	{endif}		
{end}

'---------------------------------------

{trigger:cp_wischer_schnell_toggle}
	(L.L.cp_wischer_einaus_sw) 1 =
	{if}
		(L.L.cp_wischer_schnell_sw) !
		(L.L.cockpit_wischer_drehschalter_mode) 2 =
		{if}
			3 (S.L.cockpit_wischer_drehschalter_mode)
			1 (S.L.cp_wischer_schnell_sw)
		{else}
			(L.L.cockpit_wischer_drehschalter_mode) 3 =
			{if}
				2 (S.L.cockpit_wischer_drehschalter_mode)
				0 (S.L.cp_wischer_schnell_sw)
			{endif}
		{endif}
		(C.L.wiper_lever) !
		{if}
			l1 (M.L.kippschaltersound)
		{endif}
	{endif}
{end}
	
{trigger:kw_wipermode_up}
	(L.L.cp_wischer_einaus_sw) ! (S.L.cp_wischer_einaus_sw) s1
	{if}
		2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		(L.L.cp_wischer_intervall_sw) !
		{if}
			(T.L.ev_wischerhebel)
		{endif}
	{else}
		(L.L.cp_wischer_intervall_sw)
		{if}
			1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			1 3 / (S.L.cockpit_wischerhebel) 
			0 (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel) 
			1 3 / (S.L.cockpit_wischer_drehschalter)
			(T.L.ev_wischerhebel)
		{endif}
	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_intervall_toggle}
	(L.L.cp_wischer_intervall_sw) ! (S.L.cp_wischer_intervall_sw) s1
	(L.L.cp_wischer_einaus_sw) ! &&
	{if}
		1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		1 3 / (S.L.cockpit_wischerhebel) 
		0 (S.L.cockpit_wischer_drehschalter)
	{else}
		(L.L.cp_wischer_einaus_sw)
		{if}
			2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel)
			1 3 / (S.L.cockpit_wischer_drehschalter)
		{endif}

	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button}
	1 (S.L.cp_wischer_wascher_sw)
{end}

{trigger:cp_wischer_wascher_button_off}
	0 (S.L.cp_wischer_wascher_sw) s1
{end}

{trigger:cp_heizluefter_toggle}
	(L.L.cp_heizluefter_sw) ! (S.L.cp_heizluefter_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizluefter2_toggle}
	(L.L.cp_heizluefter2_sw) ! (S.L.cp_heizluefter2_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_klimator_sw_drag}
	(L.S.mouse_y) -100 / (L.L.cp_klimator_sw) + (S.L.cp_klimator_sw) s0
	l0 0 <
	{if}
		0 (S.L.cp_klimator_sw)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_klimator_sw)
	{endif}
{end}

{trigger:cp_rollo_drag}

	(L.L.cp_rollo_pos) (S.L.cp_rollo_lastpos)

	1 (S.L.cp_rollo_dragged)
	0 (S.L.cp_rollo_speed)
	(L.S.mouse_y) 500 / (L.L.cp_rollo_pos) + (S.L.cp_rollo_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rollo_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rollo_pos)
	{endif}	

	(L.L.cp_rollo_pos) (L.L.cp_rollo_lastpos) - abs (L.S.Timegap) / (S.L.cp_rollo_speed)
{end}

{trigger:cp_rollo_off}
	0 (S.L.cp_rollo_dragged)
	(T.L.ev_rollo_end)
{end}

{trigger:cp_rollo_retract}
	(L.L.cp_rollo_bommel) 0 = (L.L.cp_rollo_pos) &&
	{if}
		(T.L.ev_rollo_retract)
	{endif}
	1 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract)
{end}

{trigger:cp_rollo_retract_off}
	0 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract) (S.L.cp_rollo_speed)
{end}

'---------------------------------------
'	12V
'---------------------------------------
{trigger:elec_12V_toggle}
	(L.L.bt_elec_12v) ! (S.L.bt_elec_12v)
	(M.L.kippschaltersound)
{end}

'---------------------------------------
'	ABS
'---------------------------------------
{trigger:ABS_toggle}
	(L.L.bt_abs) ! (S.L.bt_abs)
	(M.L.kippschaltersound)
{end}

'---------------------------------------
'	Validator
'---------------------------------------
{trigger:Validator_toggle}
	(L.L.bt_val) ! (S.L.bt_val)
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Книлинг
'-------------------------------------------
'	кнопка "автонаклон"
{trigger:cp_kneel_AI}
	(L.L.bt_kneel_al) ! (S.L.bt_kneel_al)
	(L.L.kneel_allowed) ! (S.L.kneel_allowed)
	(T.L.ev_haltebremse_sw_an)
{end}

{trigger:cp_kneel_AI_off}
	0 (S.L.bt_kneel_al)
{end}

'	кнопка "опускание"
{trigger:cp_kneel_L}
	(L.L.bt_kneel_l) ! (S.L.bt_kneel_l)
	(L.L.kneel_l) ! (S.L.kneel_l)
	(T.L.ev_haltebremse_sw_an)
{end}

{trigger:cp_kneel_L_off}
	0 (S.L.bt_kneel_l)
	0 (S.L.kneel_l)
{end}

'	кнопка "подъём"
{trigger:cp_kneel_Lif}
	(L.L.bt_kneel_lif) ! (S.L.bt_kneel_lif)
	(L.L.kneel_lif) ! (S.L.kneel_lif)
	(T.L.ev_haltebremse_sw_an)
{end}

{trigger:cp_kneel_Lif_off}
	0 (S.L.bt_kneel_lif)
	0 (S.L.kneel_lif)
{end}

'	кнопка "возврат"
{trigger:cp_kneel_R}
	(L.L.bt_kneel_r) ! (S.L.bt_kneel_r)
	(L.L.kneel_r) ! (S.L.kneel_r)
	(T.L.ev_haltebremse_sw_an)
{end}

{trigger:cp_kneel_R_off}
	0 (S.L.bt_kneel_r)
{end}

'-------------------------------------------
'	Регулятор яркости подсветки приборов
'-------------------------------------------
{trigger:Pribiri_light_drag}
	(L.S.mouse_x) 200 / (L.L.bt_plight_pos) + 0 max 1 min (S.L.bt_plight_pos)
{end}

'------------------------------------
'Крышка мототсека
'------------------------------------
{trigger:Motortuer_drag}

	1 (S.L.motortuer_dragged)
	(L.L.motortuer_pos) (S.L.motortuer_lastpos)

	(L.S.mouse_x) -200 / (L.L.motortuer_pos) + (S.L.motortuer_pos) s0
	l0 0 <
	{if}
		0 (S.L.motortuer_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.motortuer_pos)
	{endif}
	
	(L.L.bottle_visible) 1 =
	{if}
		(L.L.motortuer_pos) 0.06 <
		{if}
			0.06 (S.L.motortuer_pos)
		{endif}
	{endif}

	(L.L.motortuer_pos) (L.L.motortuer_lastpos) - (L.S.Timegap) / (S.L.motortuer_speed)
{end}

{trigger:Motortuer_off}
	0 (S.L.motortuer_dragged)
{end}

{trigger:Bottle}
	(L.L.motortuer_pos) 0.05 >
	{if}
		(L.L.bottle_visible) ! (S.L.bottle_visible)
	{endif}
{end}

'------------------------------------
'Крышка щитка реле
'------------------------------------
{trigger:cp_Sr_drag}

	1 (S.L.cp_sr_dragged)
	(L.L.cp_sr_pos) (S.L.cp_sr_lastpos)

	(L.S.mouse_x) -200 / (L.L.cp_sr_pos) + (S.L.cp_sr_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_sr_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_sr_pos)
	{endif}

	(L.L.cp_sr_pos) (L.L.cp_sr_lastpos) - (L.S.Timegap) / (S.L.cp_sr_speed)
{end}


{trigger:cp_Sr_off}
	0 (S.L.cp_sr_dragged)
{end}


'------------------------------------
'	Пандус для инвалидов
'------------------------------------
{trigger:Pandus_drag}

	1 (S.L.pandus_dragged)
	(L.L.pandus_pos) (S.L.pandus_lastpos)

	(L.S.mouse_y) -200 / (L.L.pandus_pos) + (S.L.pandus_pos) s0
	l0 0 <
	{if}
		0 (S.L.pandus_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.pandus_pos)
	{endif}
'	Открыт или закрыт пандус.		
	(L.L.pandus_pos) 0.4 > (L.L.door_2L) &&
	{if}
		1 (S.L.pandus_opn)
		0 (S.L.pandus_cls)
	{endif}
	(L.L.pandus_pos) 0.2 < (L.L.door_2L) &&
	{if}
		1 (S.L.pandus_cls)
		0 (S.L.pandus_opn)
	{endif}
	(L.L.pandus_opn) (L.L.door_2L) 0.9 < &&
	{if}
		(L.L.pandus_pos) 0.45 < 
		{if}
			0.45 (S.L.pandus_pos)
		{endif}
	{endif}
	(L.L.pandus_cls) (L.L.door_2L) 0.9 < &&
	{if}
		(L.L.pandus_pos) 0.1 > 
		{if}
			0.1 (S.L.pandus_pos)
		{endif}
	{endif}
	(L.L.pandus_pos) (L.L.pandus_lastpos) - (L.S.Timegap) / (S.L.pandus_speed)
{end}


{trigger:Pandus_off}
	0 (S.L.pandus_dragged)
{end}


'++++++++++++++++++++++++++++++++++++
'------------------------------------
'Форточки
'------------------------------------
'	Водительская
'------------------------------------
{trigger:cp_fahrerfenster_opn_drag}

	(L.L.cp_fahrerfenster_pos) (S.L.cp_fahrerfenster_lastpos)
	
	(L.L.fixator_pos) 0.3 >
	{if}
		(L.S.mouse_x) -500 (L.L.fixator_pos) / / (L.L.cp_fahrerfenster_pos) + (S.L.cp_fahrerfenster_pos) s0
		l0 0 <
		{if}
			0 (S.L.cp_fahrerfenster_pos)
			(L.L.cp_fahrerfenster_endanschlag) !
			{if}
				(T.L.ev_fahrerfenster_cls)
			{endif}
			1 (S.L.cp_fahrerfenster_endanschlag)
			
		{endif}
		l0 1 >
		{if}
			1 (S.L.cp_fahrerfenster_pos)
			(L.L.cp_fahrerfenster_endanschlag) !
			{if}
				(T.L.ev_fahrerfenster_opn)
			{endif}
			1 (S.L.cp_fahrerfenster_endanschlag)
		{endif}

		(L.L.cp_fahrerfenster_pos) s0 0 > l0 1 < &&
		{if}
			0 (S.L.cp_fahrerfenster_endanschlag)
		{endif}
	{endif}

	(L.L.cp_fahrerfenster_pos) (L.L.cp_fahrerfenster_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_fahrerfenster_opn_off}
	0 (S.L.cp_fahrerfenster_speed)
{end}

'------------------------------------
'Первая правая
'------------------------------------
{trigger:cp_f1_r_opn_drag}
	(L.L.cp_f1_r_pos) (S.L.cp_f1_r_lastpos)
	(L.S.mouse_x) 200 / (L.L.cp_f1_r_pos) + (S.L.cp_f1_r_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_f1_r_pos)
		(L.L.cp_f1_r_endanschlag) !
		{if}
			(T.L.ev_f1_r_cls)
		{endif}
		1 (S.L.cp_f1_r_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_f1_r_pos)
		(L.L.cp_f1_r_endanschlag) !
		{if}
			(T.L.ev_f1_r_opn)
		{endif}
		1 (S.L.cp_f1_r_endanschlag)
	{endif}
	(L.L.cp_f1_r_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_f1_r_endanschlag)
	{endif}
	(L.L.cp_f1_r_pos) (L.L.cp_f1_r_lastpos) - abs (L.S.Timegap) / (S.L.cp_f1_r_speed)
{end}

{trigger:cp_f1_r_opn_off}
	0 (S.L.cp_f1_r_speed)
{end}

'------------------------------------
'Вторая правая
'------------------------------------
{trigger:cp_f2_r_opn_drag}
	(L.L.cp_f2_r_pos) (S.L.cp_f2_r_lastpos)
	(L.S.mouse_x) 200 / (L.L.cp_f2_r_pos) + (S.L.cp_f2_r_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_f2_r_pos)
		(L.L.cp_f2_r_endanschlag) !
		{if}
			(T.L.ev_f2_r_cls)
		{endif}
		1 (S.L.cp_f2_r_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_f2_r_pos)
		(L.L.cp_f2_r_endanschlag) !
		{if}
			(T.L.ev_f2_r_opn)
		{endif}
		1 (S.L.cp_f2_r_endanschlag)
	{endif}
	(L.L.cp_f2_r_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_f2_r_endanschlag)
	{endif}
	(L.L.cp_f2_r_pos) (L.L.cp_f2_r_lastpos) - abs (L.S.Timegap) / (S.L.cp_f2_r_speed)
{end}

{trigger:cp_f2_r_opn_off}
	0 (S.L.cp_f2_r_speed)
{end}

'------------------------------------
'Первая левая
'------------------------------------
{trigger:cp_f1_l_opn_drag}
	(L.L.cp_f1_l_pos) (S.L.cp_f1_l_lastpos)
	(L.S.mouse_x) -200 / (L.L.cp_f1_l_pos) + (S.L.cp_f1_l_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_f1_l_pos)
		(L.L.cp_f1_l_endanschlag) !
		{if}
			(T.L.ev_f1_l_cls)
		{endif}
		1 (S.L.cp_f1_l_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_f1_l_pos)
		(L.L.cp_f1_l_endanschlag) !
		{if}
			(T.L.ev_f1_l_opn)
		{endif}
		1 (S.L.cp_f1_l_endanschlag)
	{endif}
	(L.L.cp_f1_l_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_f1_l_endanschlag)
	{endif}
	(L.L.cp_f1_l_pos) (L.L.cp_f1_l_lastpos) - abs (L.S.Timegap) / (S.L.cp_f1_l_speed)
{end}

{trigger:cp_f1_l_opn_off}
	0 (S.L.cp_f1_l_speed)
{end}

'------------------------------------
'Вторая левая
'------------------------------------
{trigger:cp_f2_l_opn_drag}
	(L.L.cp_f2_l_pos) (S.L.cp_f2_l_lastpos)
	(L.S.mouse_x) -200 / (L.L.cp_f2_l_pos) + (S.L.cp_f2_l_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_f2_l_pos)
		(L.L.cp_f2_l_endanschlag) !
		{if}
			(T.L.ev_f2_l_cls)
		{endif}
		1 (S.L.cp_f2_l_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_f2_l_pos)
		(L.L.cp_f2_l_endanschlag) !
		{if}
			(T.L.ev_f2_l_opn)
		{endif}
		1 (S.L.cp_f2_l_endanschlag)
	{endif}
	(L.L.cp_f2_l_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_f2_l_endanschlag)
	{endif}
	(L.L.cp_f2_l_pos) (L.L.cp_f2_l_lastpos) - abs (L.S.Timegap) / (S.L.cp_f2_l_speed)
{end}

{trigger:cp_f2_l_opn_off}
	0 (S.L.cp_f2_l_speed)
{end}

'------------------------------------
'Третья левая
'------------------------------------
{trigger:cp_f3_l_opn_drag}
	(L.L.cp_f3_l_pos) (S.L.cp_f3_l_lastpos)
	(L.S.mouse_x) -200 / (L.L.cp_f3_l_pos) + (S.L.cp_f3_l_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_f3_l_pos)
		(L.L.cp_f3_l_endanschlag) !
		{if}
			(T.L.ev_f3_l_cls)
		{endif}
		1 (S.L.cp_f3_l_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_f3_l_pos)
		(L.L.cp_f3_l_endanschlag) !
		{if}
			(T.L.ev_f3_l_opn)
		{endif}
		1 (S.L.cp_f3_l_endanschlag)
	{endif}
	(L.L.cp_f3_l_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_f3_l_endanschlag)
	{endif}
	(L.L.cp_f3_l_pos) (L.L.cp_f3_l_lastpos) - abs (L.S.Timegap) / (S.L.cp_f3_l_speed)
{end}

{trigger:cp_f3_l_opn_off}
	0 (S.L.cp_f3_l_speed)
{end}


'------------------------------------
'Форточка на перегородке
'------------------------------------
{trigger:cp_fp_opn_drag}
	(L.L.cp_fp_pos) (S.L.cp_fp_lastpos)
	(L.S.mouse_x) -200 / (L.L.cp_fp_pos) + (S.L.cp_fp_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fp_pos)
		(L.L.cp_fp_endanschlag) !
		{if}
			(T.L.ev_fp_cls)
		{endif}
		1 (S.L.cp_fp_endanschlag)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fp_pos)
		(L.L.cp_fp_endanschlag) !
		{if}
			(T.L.ev_fp_opn)
		{endif}
		1 (S.L.cp_fp_endanschlag)
	{endif}
	(L.L.cp_fp_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fp_endanschlag)
	{endif}

	(L.L.cp_fp_pos) (L.L.cp_fp_lastpos) - abs (L.S.Timegap) / (S.L.cp_fp_speed)
{end}


{trigger:cp_fp_opn_off}
	0 (S.L.cp_fp_speed)
{end}


'------------------------------------
'Левое зеркало
'------------------------------------
{trigger:cp_refl_trans_drag}
	(L.S.mouse_y) 150 / (L.L.cp_refl_trans_pos) + 0 max 1 min (S.L.cp_refl_trans_pos)
{end}

{trigger:cp_refl_rot_drag}
	(L.S.mouse_x) 150 / (L.L.cp_refl_rot_pos) + 0 max 1 min (S.L.cp_refl_rot_pos)
{end}

'------------------------------------
'Правое зеркало
'------------------------------------
{trigger:cp_refr_trans_drag}
	(L.S.mouse_y) 150 / (L.L.cp_refr_trans_pos) + 0 max 1 min (S.L.cp_refr_trans_pos)
{end}


{trigger:cp_refr_rot_drag}
	(L.S.mouse_x) 150 / (L.L.cp_refr_rot_pos) + 0 max 1 min (S.L.cp_refr_rot_pos)
{end}

'--------------------------------------
'	Люки
'--------------------------------------
{trigger:hatch_1}
	(L.L.hatch_1_rot1) ! (L.L.hatch_1_rot2) ! (L.L.hatch_1_trans) ! && &&
	{if}
		1 (S.L.hatch_1_rot1)
		0.4 (S.L.hatch_1)
		(T.L.ev_klappfenster_opn)
	{else}
		(L.L.hatch_1_rot1)
		{if}
			1 (S.L.hatch_1_trans)
			0 (S.L.hatch_1_rot1)
			1 (S.L.hatch_1)
			(T.L.ev_klappfenster_opn)
		{else}
			(L.L.hatch_1_trans)
			{if}
				1 (S.L.hatch_1_rot2)
				0.4 (S.L.hatch_1)
				0
				(S.L.hatch_1_rot1)
				(S.L.hatch_1_trans)
				(T.L.ev_klappfenster_cls)
			{else}
				0
				(S.L.hatch_1_rot1)
				(S.L.hatch_1_rot2)
				(S.L.hatch_1_trans)
				(S.L.hatch_1)
				(T.L.ev_klappfenster_cls)
			{endif}
		{endif}
	{endif}
{end}

{trigger:hatch_2}
	(L.L.hatch_2_rot1) ! (L.L.hatch_2_rot2) ! (L.L.hatch_2_trans) ! && &&
	{if}
		1 (S.L.hatch_2_rot1)
		0.4 (S.L.hatch_1)
		(T.L.ev_klappfenster_opn)
	{else}
		(L.L.hatch_2_rot1)
		{if}
			1 (S.L.hatch_2_trans)
			0 (S.L.hatch_2_rot1)
			1 (S.L.hatch_2)
			(T.L.ev_klappfenster_opn)
		{else}
			(L.L.hatch_2_trans)
			{if}
				1 (S.L.hatch_2_rot2)
				0.4 (S.L.hatch_2)
				0
				(S.L.hatch_2_rot1)
				(S.L.hatch_2_trans)
				(T.L.ev_klappfenster_cls)
			{else}
				0
				(S.L.hatch_2_rot1)
				(S.L.hatch_2_rot2)
				(S.L.hatch_2_trans)
				(S.L.hatch_2)
				(T.L.ev_klappfenster_cls)
			{endif}
		{endif}
	{endif}
{end}

{trigger:hatch_3}
	(L.L.hatch_3_rot1) ! (L.L.hatch_3_rot2) ! (L.L.hatch_3_trans) ! && &&
	{if}
		1 (S.L.hatch_3_rot1)
		0.4 (S.L.hatch_3)
		(T.L.ev_klappfenster_opn)
	{else}
		(L.L.hatch_3_rot1)
		{if}
			1 (S.L.hatch_3_trans)
			0 (S.L.hatch_3_rot1)
			1 (S.L.hatch_3)
			(T.L.ev_klappfenster_opn)
		{else}
			(L.L.hatch_3_trans)
			{if}
				1 (S.L.hatch_3_rot2)
				0.4 (S.L.hatch_3)
				0
				(S.L.hatch_3_rot1)
				(S.L.hatch_3_trans)
				(T.L.ev_klappfenster_cls)
			{else}
				0
				(S.L.hatch_3_rot1)
				(S.L.hatch_3_rot2)
				(S.L.hatch_3_trans)
				(S.L.hatch_3)
				(T.L.ev_klappfenster_cls)
			{endif}
		{endif}
	{endif}
{end}

'	Руль

{trigger:rudder_logo}
	(L.L.r_logo) ! (S.L.r_logo)
{end}

{trigger:cp_lenkrad_toggle}
	(L.L.cp_lenkrad_visible) ! (S.L.cp_lenkrad_visible)
{end}



{trigger:cp_batterietrennschalter_toggle}
	(L.L.elec_busbar_main_sw) ! (S.L.elec_busbar_main_sw) 
	(L.L.cp_batterietrennschalter_antirepeat) !
	{if}
		(L.L.elec_busbar_main_sw)
		{if}
			1 (S.L.bremse_ABS_selftest)
		{endif}
		1 (S.L.cp_batterietrennschalter_antirepeat)
		(T.L.ev_haltebremse_sw_an)
	{endif}
{end}
			
{trigger:cp_batterietrennschalter_toggle_off}
	0 (S.L.cp_batterietrennschalter_antirepeat)
{end}			



{trigger:cp_Fahrertuer_drag}

	1 (S.L.cp_fahrertuer_dragged)
	(L.L.cp_fahrertuer_pos) (S.L.cp_fahrertuer_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_fahrertuer_pos) + (S.L.cp_fahrertuer_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrertuer_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrertuer_pos)
	{endif}

	(L.L.cp_fahrertuer_pos) (L.L.cp_fahrertuer_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_speed)
{end}


{trigger:cp_Fahrertuer_off}
	0 (S.L.cp_fahrertuer_dragged)
{end}



{trigger:KR_play}
	(L.L.cockpit_KR_play) 0.1 < 
	{if}
		(T.L.ev_kr_play)
	{endif}
	1 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	0 (S.L.am_power) (S.L.play)
{end}


{trigger:KR_play_off}
	0.8 (S.L.cockpit_KR_play)
{end}

{trigger:KR_stop}
	1 (S.L.cockpit_KR_stop)
	0 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	(T.L.ev_kr_stop)
{end}


{trigger:KR_stop_off}
	0 (S.L.cockpit_KR_stop)
{end}


{trigger:taster_standheizung}

	(L.L.cp_taster_standheizung_target) ! (S.L.cp_taster_standheizung_target) s1

	1 (S.L.cp_taster_standheizung)

	(C.L.auxheat_via_button) !
	{if}
		l1 (M.L.kippschaltersound)
		l0 (S.L.cp_taster_standheizung)
	{endif}
		
{end}

{trigger:taster_standheizung_off}
	
	(L.L.cp_taster_standheizung_target)
	{if}
		0 (S.L.cp_taster_standheizung)
	{else}
		0.6 (S.L.cp_taster_standheizung)
	{endif}

{end}

'Колёсико стеклоочистителя
{trigger:cp_wiper_turnswitch_drag}

	(L.S.mouse_y) abs (L.S.mouse_x) abs >=
	{if}
		(L.S.mouse_y) -50 / (L.L.cockpit_wischer_drehschalter) + 0 max 1 min (S.L.cockpit_wischer_drehschalter) s0
	
'		Stufen:
'		0: Aus
'		1: Intervall
'		2: Langsam
'		3: Schnell

		l0 0.17 <
		{if}
			0 (S.L.cockpit_wischer_drehschalter_mode) (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)		
		{else} 
			l0 0.5 <
			{if}
				0 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
				1 (S.L.cockpit_wischer_drehschalter_mode) (S.L.cp_wischer_intervall_sw)
			{else}
				l0 0.83 <
				{if}
					2 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw)
					0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
				{else}
					3 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
					0 (S.L.cp_wischer_intervall_sw)
				{endif}
			{endif}
		{endif}
	{else}
		(L.S.mouse_x) 100 / (L.L.cockpit_wischerhebel_x) + (S.L.cockpit_wischerhebel_x) s1	
			
		l1 0.9 >
		{if}
			(L.L.cp_wischer_wascher_sw) !
			1 (S.L.cp_wischer_wascher_sw)
		{else}
			(L.L.cp_wischer_wascher_sw) !
			0 (S.L.cp_wischer_wascher_sw)
		{endif}
	{endif}
{end}

{trigger:cp_wiper_turnswitch_off}
	(L.L.cp_wischer_wascher_sw) !
	0 (S.L.cp_wischer_wascher_sw)

'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischer_drehschalter_mode) 3 / (S.L.cockpit_wischer_drehschalter)
{end}

	
{trigger:cp_microphone}
	1 (S.L.inf_bt_mkf)
{end}

{trigger:cp_microphone_off}
	0 (S.L.inf_bt_mkf)
{end}



{trigger:cp_heizregler_defrost_drag}
	(L.S.mouse_x) -70 / (L.L.cockpit_heizregler_defrost) + 0 max 1 min (S.L.cockpit_heizregler_defrost)
{end}

{trigger:cp_heizregler_fussraum_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_fussraum) + 0 max 1 min (S.L.cockpit_heizregler_fussraum)
{end}

{trigger:cp_heizregler_temp_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_temp) + 0 max 1 min (S.L.cockpit_heizregler_temp)
{end}

{trigger:cp_heizregler_bug_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_bug) + 0 max 1 min (S.L.cockpit_heizregler_bug)
{end}

{trigger:cp_heizregler_umluft_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_umluft) + 0 max 1 min (S.L.cockpit_heizregler_umluft) s0

'	Stufen:
'	0: Umluftheizung
'	1: Direktbelьftung
'	2: Frischluftheizung

	l0 0.2 <
	{if}
		0 (S.L.cockpit_heizregler_ventilation_mode)
	{else}
		l0 0.8 <
		{if}
			1 (S.L.cockpit_heizregler_ventilation_mode)
		{else}
			2 (S.L.cockpit_heizregler_ventilation_mode)
		{endif}
	{endif}

{end}

{trigger:cp_heizregler_umluft_off}
	(L.L.cockpit_heizregler_ventilation_mode) 2 / (S.L.cockpit_heizregler_umluft)

{end}

'-------------------------------------------
'Переключатель аварийного останова двигателя и выключения "массы" и его крышка
'-------------------------------------------

{trigger:cp_avariinoe_vykl_kryshka}
	(L.L.cp_avariinoe_vykl_kryshka) !
	{if}
		1 (S.L.cp_avariinoe_vykl_kryshka)
		(T.L.ev_avar_kr)
	{else}
		(L.L.cp_avar_rot) 0.1 <
		{if}
			0 (S.L.cp_avariinoe_vykl_kryshka)
			(T.L.ev_avar_kr)
		{endif}
	{endif}
	
{end}

{trigger:cp_avar_mov_drag}

	(L.L.cp_avariinoe_vykl_kryshka) !
	{if}
		1 6 / (S.L.cp_avar_rot_max)
	{else}
		1 (S.L.cp_avar_rot_max)
	{endif}

	(L.S.mouse_x) -20 / (L.L.cp_avar_rot) + 0 max (L.L.cp_avar_rot_max) min (S.L.cp_avar_rot) s1

	l1 0.2 <
	{if}
		0 (S.L.cp_avar_rot_mode)			
	{else} 
		l1 0.9 >
		{if}
			0 (S.L.engine_injection_on)
			(L.L.elec_busbar_main)
			{if}
				0 (S.L.elec_busbar_main_sw)
			{endif}
					
			1 (S.L.cp_avar_rot_mode)
		{endif}
	{endif}
{end}

{trigger:cp_avar_mov_off}

'	Привязка ключа к фиксированным положениям
	(L.L.cp_avar_rot_mode) 2 / (S.L.cp_avar_rot)

{end}


{trigger:kolpak_1l}
	(L.L.kolpak_1l) ! (S.L.kolpak_1l)
	(T.L.ev_kolpak_1l)
{end}

{trigger:kolpak_1r}
	(L.L.kolpak_1r) ! (S.L.kolpak_1r)
	(T.L.ev_kolpak_1r)
{end}

{trigger:kolpak_2l}
	(L.L.kolpak_2l) !
	{if}
		1 (S.L.kolpak_2l)
		(T.L.ev_kolpaksound_cls)
	{else}
		0 (S.L.kolpak_2l)
		(T.L.ev_kolpaksound_opn)
	{endif}
{end}

{trigger:kolpak_2r}
	(L.L.kolpak_2r) !
	{if}
		1 (S.L.kolpak_2r)
		(T.L.ev_kolpaksound_cls)
	{else}
		0 (S.L.kolpak_2r)
		(T.L.ev_kolpaksound_opn)
	{endif}
{end}


{trigger:cp_bt_obduv}
	(L.L.bt_obduv) 
	{if}
		0 (S.L.bt_obduv) s1
	{else}
		1 (S.L.bt_obduv) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

{trigger:Mirror_obogrev}
	(L.L.bt_mirror_obogrev) ! (S.L.bt_mirror_obogrev) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw01}
	(L.L.cp_dummy_sw01) ! (S.L.cp_dummy_sw01) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw02}
	(L.L.cp_dummy_sw02) ! (S.L.cp_dummy_sw02) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw03}
	(L.L.cp_dummy_sw03) ! (S.L.cp_dummy_sw03) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw04}
	(L.L.cp_dummy_sw04) ! (S.L.cp_dummy_sw04) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_per_polka_drag}
	(L.S.mouse_y) -70 / (L.L.polka_pos) + 0 max 1 min (S.L.polka_pos)
{end}

{trigger:cp_fort_fixator_drag}
	(L.S.mouse_x) -250 / (L.L.fixator_pos) + 0 max 1 min (S.L.fixator_pos)
{end}



'----------------------
'	Init
'----------------------

{macro:cockpit_init}
	0.7 (S.L.cockpit_gangN)
	0 (S.L.cockpit_hupe_volume) (S.L.door_handsteuerung)
	1 (S.L.cp_retarder_sw) (S.L.cp_lenkrad_visible) (S.L.cp_taster_warnblinker) (S.L.cockpit_wischer_drehschalter_mode) 

	0.6 (S.L.cp_taster_warnblinker) (S.L.cp_taster_standheizung)

	(C.L.cockpit_zentralschmierung_dist) random (S.L.cp_zentralschmierung_nextkm)

	0.333 (S.L.cockpit_wischer_drehschalter)
	
	1 (S.L.pandus_cls)
	
	
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}

'Ьbertragen der Schalterstellungen:
	(L.L.cp_retarder_sw) (S.L.antrieb_retarder_sw)
	(L.L.cp_retarder_sw_direkt) (S.L.antrieb_retarder_sw_direkt)
	(L.L.cp_wischer_schnell_sw) (S.L.wiper_schnell_sw)
	(L.L.cp_wischer_einaus_sw) (S.L.wiper_einaus_sw)
	(L.L.cp_wischer_intervall_sw) (S.L.wiper_intervall_sw)
	(L.L.cp_wischer_wascher_sw) (S.L.wiper_wascher_sw)

	(M.L.tacho_frame)
	(M.L.tachometr_frame)
	(M.L.uhr_frame)
	(M.L.drehzahlmesser_frame)
	(M.L.hupe_frame)
	(M.L.wischerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.tankuhr_frame)
	(M.L.cockpitlights_frame)
	(M.L.klimator_frame)
	(M.L.odometer_frame)
	(M.L.fahrertuer_frame)	
	(M.L.rollo_frame)
	(M.L.engine_thermometer_frame)
	(M.L.microphone_frame)
	(M.L.pressure_warning_needle_frame)
	(M.L.zentralschmierung_frame)
	(M.L.Thermometer_frame)
	(M.L.ampermetr_frame)
	(M.L.reletuer_frame)
	(M.L.pandus_frame)
	(M.L.motortuer_frame)
	(M.L.bk08_frame)
	(M.L.windows_frame)
	

' Мигание ":" на часах
	(L.L.Time_timer) (S.L.Time_timer_last)

	(L.L.Time_timer) 1 <
	{if}
		(L.L.Time_timer) (L.S.Timegap) 2 * + (S.L.Time_timer)
	{else}
		0 (S.L.Time_timer)
	{endif}
	
	(L.L.Time_timer) (L.L.Time_timer_last) !
	{if}
		(L.L.Time_BlinkOn) ! (S.L.Time_BlinkOn)
	{endif}
	
	(L.L.timer_01) s0
	(L.L.timer_01) 1 <
	{if}
		(L.L.timer_01) (L.S.Timegap) 1.9 * + (S.L.timer_01)
	{else}
		0 (S.L.timer_01)
	{endif}
	(L.L.timer_01) l0 !
	{if}
		(L.L.Lamp01_BlinkOn) ! (S.L.Lamp01_BlinkOn)
	{endif}
		
{end}

'-------------------------------------
' Спидометр
'-------------------------------------
{macro:tacho_frame}
	(L.L.Velocity) (F.L.cockpit_tacholinie) (S.L.cp_speed_arrow)
{end}


'-------------------------------------
' Тахометр
'-------------------------------------
{macro:tachometr_frame}
	(L.L.engine_n) (F.L.cp_taho) (S.L.cp_taho_arrow)
{end}


{macro:uhr_frame}
	(L.S.Time) s0 60 / (S.L.cockpit_uhr_min) 12 / (S.L.cockpit_uhr_std)
	l0 trunc (S.L.cockpit_uhr_sek)
{end} 

{macro:drehzahlmesser_frame}
	(L.L.engine_n) 3000 270 / / (S.L.cockpit_drehzahlwinkel)
{end}



{macro:hupe_frame}
	(L.L.elec_busbar_main)
	{if}
		(L.L.cockpit_hupe) 1 =
		{if}
			(L.L.cockpit_hupe_volume) 1 <
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * + (S.L.cockpit_hupe_volume)
			{else}
				1 (S.L.cockpit_hupe_volume)
			{endif}
		{else}
			(L.L.cockpit_hupe_volume) 0 >
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
			{else}
				0 (S.L.cockpit_hupe_volume)
			{endif}
		{endif}
	{else}
		(L.L.cockpit_hupe_volume) 0 >
		{if}
			(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
		{else}
			0 (S.L.cockpit_hupe_volume)
		{endif}
	{endif}	
	
{end}

{macro:wischerhebel_frame}

	(L.L.cockpit_wischerhebel_lastmode) (L.L.cockpit_wischerhebel_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischerhebel_lastmode)
{end}

{macro:wischer_drehschalter_frame}

	(L.L.cockpit_wischer_drehschalter_lastmode) (L.L.cockpit_wischer_drehschalter_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}



{macro:cockpitlights_frame}

'	AKPP
	(L.L.antrieb_getr_gangwahl) 0 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gangR) 0 > &&
	(S.L.lights_zf_R)
	
	(L.L.antrieb_getr_gangwahl) 1 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gangN) 0 > &&
	(S.L.lights_zf_N)
	
	(L.L.antrieb_getr_gangwahl) 7 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gangD) 0 > &&
	(S.L.lights_zf_D)
	
	(L.L.antrieb_getr_gangwahl) 2 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gang1) 0 > &&
	(S.L.lights_zf_1)
	
	(L.L.antrieb_getr_gangwahl) 3 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gang2) 0 > &&
	(S.L.lights_zf_2)
	
	(L.L.antrieb_getr_gangwahl) 4 = (L.L.elec_busbar_main) &&
	(L.L.cockpit_gang3) 0 > &&
	(S.L.lights_zf_3)


'	Retarder
	(L.L.antrieb_retarder) (L.L.elec_busbar_main_sw) &&
	(S.L.light_antrieb_retarder)

	(L.L.matrix_power) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_bt_matrix)

'	12V
	(L.L.bt_elec_12v) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_elec_12v)
	(S.L.elec_12v)

'	ABS button	
	(L.L.bt_abs) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_bt_abs)
	
'	Validator	
	(L.L.bt_val) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_validator)
	
'	Obduv
	(L.L.bt_obduv) 1 = (L.L.elec_busbar_main) &&
	(S.L.obduv)
	
	

'	Подсветка IBIS
	(L.L.ibis_power) 1 = (L.L.elec_busbar_main) (L.L.elec_12v) && &&
	(S.L.lights_ibis)
	
'	Кнопки освещения салона	
	(L.L.bt_salon1_light) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_bt_salon)
	
	(L.L.bt_salon2_light) 1 = (L.L.elec_busbar_main) &&
	(S.L.lights_bt_salon1)
	
'	light_ampermetr
'	lights_oellamp
'	lights_fuellamp
'	light_engtemp

	(L.L.light_ampermetr) (L.L.lights_oellamp) (L.L.lights_fuellamp) (L.L.light_engtemp) || || ||
	(L.L.elec_busbar_main) &&
	(S.L.light_warnlamp)
	
	(L.L.elec_busbar_main) (L.L.p_norm) 0 = &&
	(L.L.Time_BlinkOn) &&
	(S.L.kniling_off)

	(L.L.elec_busbar_main) (L.L.p_norm) 1 = &&
	(S.L.kniling_on)
	
'	Лампа работы ASR	
	(L.L.engine_ASR_eingriff) (L.L.elec_busbar_main_sw) &&
	(S.L.light_ASR)
	
'	Лампа-индикатор низкого давления в 1-ом контуре
'	Лампа-индикатор низкого давления в 2-ом контуре
	(L.L.bremse_p_tank02) 570000 < (L.L.Time_BlinkOn) &&
	(L.L.elec_busbar_main) &&
	(S.L.light_tank2)
	
'	Лампа-индикатор низкого давления в 3-ем контуре
	(L.L.bremse_p_tank03) 570000 < (L.L.Time_BlinkOn) &&
	(L.L.elec_busbar_main) &&
	(S.L.light_tank3)
	
'	Лампа-индикатор низкого давления в 4-ом контуре
	(L.L.bremse_p_tank04) 570000 < (L.L.Time_BlinkOn) &&
	(L.L.elec_busbar_main) &&
	(S.L.light_tank4)
	
	(L.L.bremse_feststell) (L.L.elec_busbar_main) &&
	(L.L.Lamp01_BlinkOn) &&
	(S.L.light_feststell)

	(L.L.bt_mirror_obogrev) (L.L.elec_busbar_main) &&
	(S.L.bt_light_mirror_obogrev)
	


'	Kippschalter-Beleuchtung
	(L.L.cp_retarder_sw_direkt) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_retarder_direkt)

	(L.L.cp_retarder_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_retarder)

	(L.L.cp_wischer_schnell_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_schnell)

	(L.L.cp_wischer_einaus_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_einaus)

	(L.L.cp_wischer_intervall_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_intervall)
	
	(L.L.cp_wischer_wascher_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_wascher)

	(L.L.cp_heizluefter_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_heizluefter)
	
	(L.L.cp_heizluefter2_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_heizluefter2)
	
	(L.L.cp_spiegelheizung_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_spiegelheizung)

	(L.L.cp_motorkuehlung_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_motorkuehlung)

	(L.L.door_handsteuerung) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_tuer_handsteuerung)



'	Dummy-Schalter:

	(L.L.cp_dummy_sw01) (L.L.elec_busbar_main) &&
	(S.L.cp_dummy_func01)

	(L.L.cp_dummy_sw02) (L.L.elec_busbar_main) &&
	(S.L.cp_dummy_func02)

	(L.L.cp_dummy_sw03) (L.L.elec_busbar_main) &&
	(S.L.cp_dummy_func03)

	(L.L.cp_dummy_sw04) (L.L.elec_busbar_main) &&
	(S.L.cp_dummy_func04)


{end}

'----------------------------------------
' Напряжение на аккумуляторных батареях
'----------------------------------------
{macro:ampermetr_frame}
	(L.L.elec_busbar_main)
	{if}
		(L.L.elec_V_battery) 0.8 <
		{if}
			1 (S.L.light_ampermetr)
		{else}
			0 (S.L.light_ampermetr)
		{endif}
		(L.L.elec_V_battery) (F.L.cockpit_ampermetr) s0
	{else}
		0 s0
		0 (S.L.light_ampermetr)
	{endif}

	(L.L.cockpit_ampermetr) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_ampermetr)
{end}

{macro:oeldruck_frame}
	(L.L.engine_temperature) 0 <
	{if}
		(L.S.Weather_Temperature) (L.L.engine_temperature) - -5 >
		{if}
			(L.L.engine_n) 2 /
		{else}
			(L.L.engine_n)
		{endif}
		(F.L.cockpit_oeldruck) s0
	{else}
		(L.L.engine_n) (F.L.cockpit_oeldruck) s0
	{endif}

	(L.L.elec_busbar_main) !
	{if}
		0 s0
	{endif}

	(L.L.cockpit_oeldruck) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_oeldruck)
	
	(L.L.elec_busbar_main)
	{if}
		l1 15 < l1 1 > && (S.L.lights_oellamp)
	{else}
		0 (S.L.lights_oellamp)
	{endif}
{end}

{macro:tankuhr_frame}
	(L.L.elec_busbar_main)
	{if}
		(L.L.engine_tank_content) (F.L.cockpit_tankuhr) s0 32 < (S.L.lights_fuellamp)
	{endif}

	(L.L.elec_busbar_main) !
	{if}
		0 s0 (S.L.lights_fuellamp)
	{endif}

	(L.L.cockpit_tankuhr) s1
	2 s2
	2 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_tankuhr)
{end}

{macro:engine_thermometer_frame}
	(L.L.elec_busbar_main) !
	{if}
		0 s0 (S.L.light_engtemp)
	{else}
		(L.L.engine_temperature) (F.L.cockpit_engine_temperature) s0
		(L.L.engine_temperature) 105 > (S.L.light_engtemp)
	{endif}

	(L.L.cockpit_motortemperaturwinkel) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_motortemperaturwinkel)
{end}


{macro:outside_hatches_sound}
	l1
	{if}
		(T.L.outside_hatches_sound_opn)
	{else}
		(T.L.outside_hatches_sound_cls)
	{endif}	
{end}

{macro:klappfenstersound}
	l1
	{if}
		(T.L.ev_klappfenster_opn)
	{else}
		(T.L.ev_klappfenster_cls)
	{endif}	
{end}
	

{macro:kippschaltersound}
	l1
	{if}
		(T.L.ev_kippschalter_ein)
	{else}
		(T.L.ev_kippschalter_aus)
	{endif}	
{end}

{macro:klappfenstersound}
	l1
	{if}
		(T.L.ev_klappfenster_opn)
	{else}
		(T.L.ev_klappfenster_cls)
	{endif}	
{end}


{macro:klimator_frame}

'Frontheizgerдt:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_klimator_sw) s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_klimator_RPM) > 
	{if}
		1.5 s0
	{else}
		0.5 s0
	{endif}

' Berechnung der Luefterbeschleunigung:
'Расчет ускорения вентилятора:

'Sollwert:
'заданная величина
	l1 100 * 
'Istwert:
'фактический:
	(L.L.cp_klimator_RPM)
'Beschleunigung:
'ускорение:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
'Дополнение к фактическим значением:
	(L.L.cp_klimator_RPM) + (S.L.cp_klimator_RPM)


'Raumheizgerдte:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_heizluefter_sw) s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_cabinheater_RPM) > 
	{if}
		6 s0
	{else}
		1.0 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_cabinheater_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_cabinheater_RPM) + (S.L.cp_cabinheater_RPM)

{end}

{macro:traegheit}

'Simuliert trдges Verhalten (exponentiell)
'Имитация вялым поведением

'Ladekonventionen Зарядка конвенций:
'	Sollwert		l0
'	заданное значение
'	Istwert			l1
'	Актуальное
'	Konstante Anlauf	l2 (Einheiten/s)
'	Konstante Ablauf	l3 (Einheiten/s)

'Anlauf oder Auslauf?
	l0 l1 > 
	{if}
		l2 (L.S.Timegap) * 1 min -1 max s4
	{else}
		l3 (L.S.Timegap) * 1 min -1 max s4
	{endif}


'Sollwert:
	l0
'Istwert:
	l1
'Beschleunigung:
	- l4 *
'Addition zum Istwert:
	l1 + s1
{end}

'	 Дверца водителя.
{macro:fahrertuer_frame}

	(L.L.cp_fahrertuer_dragged) !
	{if}
		(L.L.cp_fahrertuer_pos) (L.S.Timegap) (L.L.cp_fahrertuer_speed) * + (S.L.cp_fahrertuer_pos)

		(L.L.cp_fahrertuer_pos) 1 >
		{if}
			1 (S.L.cp_fahrertuer_pos)
			(L.L.cp_fahrertuer_speed) /-/ 0.7 * (S.L.cp_fahrertuer_speed)
		{endif}
		(L.L.cp_fahrertuer_pos) 0 <
		{if}
			0 (S.L.cp_fahrertuer_speed) (S.L.cp_fahrertuer_pos)
		{endif}

		(L.L.cp_fahrertuer_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_fahrertuer_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_fahrertuer_globalangle) * * + (S.L.cp_fahrertuer_speed)
		{endif}
	
		(L.L.cp_fahrertuer_speed) s0 (S.L.cp_fahrertuer_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_speed)
		{endif}


		(L.L.cp_fahrertuer_speed) 0 > (L.L.cp_fahrertuer_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_speed) 0 < (L.L.cp_fahrertuer_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_pos) 0 > (L.L.cp_fahrertuer_open) ! &&
	{if}
		(T.L.ev_fahrertuer_auf)
		1 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 0 = (L.L.cp_fahrertuer_open) &&
	{if}
		(T.L.ev_fahrertuer_zu)
		0 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}


'	Крышка щитка реле

{macro:reletuer_frame}

	(L.L.cp_sr_dragged) !
	{if}
		(L.L.cp_sr_pos) (L.S.Timegap) (L.L.cp_sr_speed) * + (S.L.cp_sr_pos)

		(L.L.cp_sr_pos) 1 >
		{if}
			1 (S.L.cp_sr_pos)
			(L.L.cp_sr_speed) /-/ 0.7 * (S.L.cp_sr_speed)
		{endif}
		(L.L.cp_sr_pos) 0 <
		{if}
			0 (S.L.cp_sr_pos)
		{endif}

		(L.L.cp_sr_pos) 0 >
		{if}
			(L.L.cp_sr_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_sr_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_sr_globalangle) * * + (S.L.cp_sr_speed)
		{endif}
	
		(L.L.cp_sr_speed) s0 (S.L.cp_sr_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_sr_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_sr_speed)
		{endif}


		(L.L.cp_sr_speed) 0 > (L.L.cp_sr_lastspeed) 0 < &&
		(L.L.cp_sr_speed) 0 < (L.L.cp_sr_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_sr_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_sr_pos) 0 > (L.L.cp_sr_open) ! &&
	{if}
		(T.L.ev_sr_auf)
		1 (S.L.cp_sr_open)
	{endif}

	(L.L.cp_sr_pos) 0 = (L.L.cp_sr_open) &&
	{if}
		(T.L.ev_sr_zu)
		0 (S.L.cp_sr_open)
	{endif}

	(L.L.cp_sr_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_sr_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}


'	Пандус...

{macro:pandus_frame}

	(L.L.pandus_dragged) !
	{if}
		(L.L.pandus_pos) (L.S.Timegap) (L.L.pandus_speed) * + (S.L.pandus_pos)
		
'	Падение(если поднят)
		(L.L.pandus_pos) 0.45 >
		{if}
			(L.L.pandus_speed) (L.S.Timegap) + (S.L.pandus_speed)
		{endif}
		
		(L.L.pandus_pos) 0.45 <
		{if}
			(L.L.pandus_speed) (L.S.Timegap) -1 * + (S.L.pandus_speed)
		{endif}
		

'	Отскок при максимальном откр.\закр.
		(L.L.pandus_pos) 1 >
		{if}
			1 (S.L.pandus_pos)
'	Отскок
			(L.L.pandus_speed) /-/ 0.2 * (S.L.pandus_speed)
		{endif}

		(L.L.pandus_pos) 0 <
		{if}
			0 (S.L.pandus_pos)
'	Отскок
			(L.L.pandus_speed) /-/ 0.2 * (S.L.pandus_speed)
		{endif}

'	Подпрыгивание при езде с открытым пандусом (на всякий... пожарный))).
		(L.L.Velocity) 100 / 0.2 min s3
		
		(L.L.pandus_pos) 1 = (L.L.Velocity) 0 > &&
		{if}
			(L.L.pandus_speed) l3 - (S.L.pandus_speed)
		{endif}

'	Полная остановка.	
		(L.L.Velocity) 2 > (L.L.pandus_pos) 0.5 > &&
		{if}
			0 (S.L.empty_01)
		{endif}
		
		(L.L.pandus_speed) 0 = !
		{if}
			(L.L.pandus_pos) 0.005 < (L.L.pandus_pos) 0.995 > ||
			{if}
				(L.L.empty_01) 1 <
				{if}
					(L.L.empty_01) (L.S.Timegap) + (S.L.empty_01)
				{else}
					0 (S.L.pandus_speed)
				{endif}
			{else}
				0 (S.L.empty_01)
			{endif}
		{endif}
	{endif}

'	Открыт или закрыт пандус.		
	(L.L.pandus_pos) 0.4 > (L.L.door_2L) &&
	{if}
		1 (S.L.pandus_opn)
		0 (S.L.pandus_cls)
	{endif}

	(L.L.pandus_pos) 0.2 < (L.L.door_2L) &&
	{if}
		1 (S.L.pandus_cls)
		0 (S.L.pandus_opn)
	{endif}

'	Отскок от закрытой двери.		
	(L.L.pandus_opn) (L.L.door_2L) 0.9 < &&
	{if}
		(L.L.pandus_pos) 0.47 < 
		{if}
			0.47 (S.L.pandus_pos)
'	Отскок
			(L.L.pandus_speed) /-/ 0.2 * (S.L.pandus_speed)
		{endif}
	{endif}
		
	(L.L.pandus_cls) (L.L.door_2L) 0.9 < &&
	{if}
		(L.L.pandus_pos) 0.1 > 
		{if}
			0.1 (S.L.pandus_pos)
'	Отскок
			(L.L.pandus_speed) /-/ 0.2 * (S.L.pandus_speed)
		{endif}
	{endif}

	(L.L.pandus_pos) 0.01 >
	{if}
		0 (S.L.pandus_close)
	{endif}

	(L.L.pandus_pos) 0 = (L.L.pandus_close) ! &&
	{if}
		1 (S.L.pandus_close)
		(T.L.ev_pandus_zu)
	{endif}
	
	(L.L.pandus_pos) 0.99 <
	{if}
		0 (S.L.pandus_open)
	{endif}

	(L.L.pandus_pos) 1 = (L.L.pandus_open) ! &&
	{if}
		(T.L.ev_pandus_zu)
		1 (S.L.pandus_open)
	{endif}
	
	(L.L.pandus_pos) 0.48 > (L.L.door_2L) ! &&
	{if}
		0 (S.L.pandus_door_stuk)
	{endif}

	(L.L.pandus_pos) 0.47 = (L.L.door_2L) ! (L.L.pandus_door_stuk) ! && &&
	{if}
		1 (S.L.pandus_door_stuk)
		(T.L.ev_pandus_zu)
	{endif}
	
	(L.L.pandus_speed) 0 <
	{if}
		(L.L.pandus_speed) /-/ (S.L.pandus_stuk_vol)
	{else}
		(L.L.pandus_speed) (S.L.pandus_stuk_vol)
	{endif}

{end}

'	Капот.
{macro:motortuer_frame}

	(L.L.motortuer_pos) 0.1 >
	{if}
	(L.L.motortuer_speed) abs (S.L.motortuer_volcurve)
'		(L.L.motortuer_speed) s0 0 <
'		{if}
'			l0 /-/ (S.L.motortuer_volcurve)
'		{else}
'			l0 (S.L.motortuer_volcurve)
'		{endif}
	{endif}

	(L.L.motortuer_dragged) !
	{if}
		(L.L.motortuer_pos) (L.S.Timegap) (L.L.motortuer_speed) * + (S.L.motortuer_pos)
		
		(L.L.motortuer_pos) 0.35 >
		{if}
			(L.L.motortuer_speed) (L.S.Timegap) + (S.L.motortuer_speed)
		{endif}
		
		(L.L.motortuer_pos) 0.35 <
		{if}
			(L.L.motortuer_speed) (L.S.Timegap) -1 * + (S.L.motortuer_speed)
		{endif}

		(L.L.motortuer_pos) 1 >
		{if}
			1 (S.L.motortuer_pos)
			(L.L.motortuer_speed) /-/ 0.2 * 0.2 min (S.L.motortuer_speed)
		{endif}
		(L.L.motortuer_pos) 0 <
		{if}
			0 (S.L.motortuer_speed) (S.L.motortuer_pos)
		{endif}

'	Полная остановка.	
		(L.L.motortuer_speed) 0 = !
		{if}
			(L.L.motortuer_pos) 0.005 < (L.L.motortuer_pos) 0.995 > ||
			{if}
				(L.L.empty_02) 1 <
				{if}
					(L.L.empty_02) (L.S.Timegap) + (S.L.empty_02)
				{else}
					0 (S.L.motortuer_speed)
				{endif}
			{else}
				0 (S.L.empty_02)
			{endif}
		{endif}
		
		(L.L.bottle_visible) 1 =
		{if}
			(L.L.motortuer_pos) 0.06 <
			{if}
				0.06 (S.L.motortuer_pos)
				(L.L.motortuer_speed) /-/ 0.1 * 0.2 min (S.L.motortuer_speed) 
			{endif}
		{endif}
	{endif}

	(L.L.motortuer_pos) 0 > (L.L.motortuer_open) ! &&
	{if}
		1 (S.L.motortuer_open)
	{endif}

	(L.L.motortuer_pos) 0 = (L.L.motortuer_open) &&
	{if}
		(T.L.ev_motortuer_cls)
		0 (S.L.motortuer_open)
	{endif}
{end}


{macro:rollo_frame}
	(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) max (S.L.cp_rollo_rastpos)
	
	(L.L.cp_rollo_pos) 0.4 >=
	{if}
		(L.L.cp_rollo_pos) 0.4 - 1.666 * (S.L.cp_rollo_pos_2) s1
		l1 0 <
		{if}
			0 (S.L.cp_rollo_pos_2)
		{endif}
		l1 1 >
		{if}
			1 (S.L.cp_rollo_pos_2)
		{endif}
	{endif}

	(L.L.cp_rollo_dragged) !
	{if}
		(L.L.cp_rollo_retract)
		{if}
			(L.L.cp_rollo_speed) (L.S.Timegap) (L.L.cp_rollo_pos) 14 * * - (S.L.cp_rollo_speed)
			(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos) 0.4 - 1.666 * (S.L.cp_rollo_pos_2)
					
		{else}
			(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) < 
			{if}
				(L.L.cp_rollo_speed) (L.S.Timegap) 14 * + (S.L.cp_rollo_speed)
				(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (L.L.cp_rollo_rastpos) min (S.L.cp_rollo_pos) 0.4 - 1.666 * (S.L.cp_rollo_pos_2)
			{else}
				0 (S.L.cp_rollo_speed)
			{endif}
		{endif}

		(L.L.cp_rollo_pos) 1 >
		{if}
			1 (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
		{else}
			(L.L.cp_rollo_pos) 0 <
			{if}
			0 (S.L.cp_rollo_pos) (S.L.cp_rollo_retract) (S.L.cp_rollo_rastpos)
			{endif}
		{endif}
		
		(L.L.cp_rollo_pos_2) 0 <
		{if}
			0 (S.L.cp_rollo_pos_2)
		{endif}
		(L.L.cp_rollo_pos_2) 1 >
		{if}
			1 (S.L.cp_rollo_pos_2)
		{endif}

	{endif}
{end}



{macro:microphone_frame}

	(L.L.inf_bt_mkf)
	(L.L.elec_busbar_main) && s0
	(L.L.Snd_Microphone) s1


	l0 l1 ! &&
	{if}
		(T.L.micro_lautsprecherknack_start)
	{endif}

	l0 ! l1 &&
	{if}
		(T.L.micro_lautsprecherknack_end)
	{endif}


	l0 (S.L.Snd_Microphone)
{end}


{macro:pressure_warning_needle_frame}

	(L.L.bremse_p_Tank01) (L.L.bremse_p_Tank02) + 2 / (S.L.cockpit_warndruck) (F.L.cockpit_warndruck) (S.L.cockpit_warndruckwinkel)

{end}

{macro:zentralschmierung_frame}

	(L.L.cp_zentralschmierung_nextkm) (L.L.velocity) 3600 / (L.S.Timegap) * + (S.L.cp_zentralschmierung_nextkm)
	(C.L.cockpit_zentralschmierung_dist) >
	(L.L.cp_zentralschmierung_runtime) (C.L.cockpit_zentralschmierung_maxtime) < &&
	{if}
		1 (S.L.cockpit_light_zentralschmierung)
		(L.L.cp_zentralschmierung_runtime) (L.S.Timegap) + (S.L.cp_zentralschmierung_runtime)
	{else}
		(L.L.cockpit_light_zentralschmierung)
		{if}
			0 (S.L.cp_zentralschmierung_nextkm)
		{endif}
		0 (S.L.cockpit_light_zentralschmierung) (S.L.cp_zentralschmierung_runtime)
	{endif}	

{end}

{macro:Thermometer_frame}

	(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh "." $+ 
	l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+
	(S.$.cockpit_temperatur)
	
'	Спиртовой термометр(уличный)

	50 (L.S.Weather_Temperature) + trunc 0 max 100 min s1
	"C" 100 $* l1 $SetLengthL (S.$.weather_temp_spirt_termometr)
	
'	Спиртовой термометр(салонный)

	50 (L.L.Cabinair_Temp) + trunc 0 max 100 min s1
	"C" 100 $* l1 $SetLengthL (S.$.cockpit_temp_spirt_termometr)
{end}

{macro:odometer_frame}
	(L.L.kmcounter_km) (L.L.kmcounter_m) 1000 / + 10 *
	(S.L.cp_odometer_01)

	(L.L.cp_odometer_01) 10 / trunc 
	(L.L.cp_odometer_01) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1)

	(L.L.cp_odometer_1) 10 / trunc 
	(L.L.cp_odometer_1) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10)

	(L.L.cp_odometer_10) 10 / trunc 
	(L.L.cp_odometer_10) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100)

	(L.L.cp_odometer_100) 10 / trunc 
	(L.L.cp_odometer_100) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1000)

	(L.L.cp_odometer_1000) 10 / trunc 
	(L.L.cp_odometer_1000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10000)

	(L.L.cp_odometer_10000) 10 / trunc 
	(L.L.cp_odometer_10000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100000)


	(L.L.kmcounter_m) 100 / (S.L.cp_odometer_01)
{end}

{trigger:BK_08_toggle}
	1 (S.L.bt_bk08)
	
	(L.L.bk08_mode) !
	{if}
		1 (S.L.bk08_mode)
	{else}
		(L.L.bk08_mode) 1 =
		{if}
			2 (S.L.bk08_mode)
		{else}
			(L.L.bk08_mode) 2 =
			{if}
				3 (S.L.bk08_mode)
			{else}
				(L.L.bk08_mode) 3 =
				{if}
					0 (S.L.bk08_mode)
				{endif}
			{endif}
		{endif}
	{endif}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
	{endif}
{end}

{trigger:BK_08_toggle_off}
	0 (S.L.bt_bk08)
{end}

{macro:bk08_frame}
	(L.L.engine_injection_on) ! (L.L.engine_injection_on_last) &&
	{if}
		5 (S.L.bk_08_timer)
		(L.L.engine_timer) (S.L.engine_timer_last)
	{endif}
	(L.L.engine_injection_on) (S.L.engine_injection_on_last)
	
	
	(L.L.engine_injection_on)
	{if}
		(L.L.engine_timer) (L.S.Timegap) + (S.L.engine_timer)
		0 (S.L.bk_08_timer)
	{else}

		(L.L.bk_08_timer) 0 >
		{if}
			(L.L.bk_08_timer) (L.S.Timegap) - (S.L.bk_08_timer)
		{endif}
		0 (S.L.engine_timer)
	{endif}
	

	(L.L.elec_busbar_main)
	{if}
'		test	
'		"2680...." (S.$.bk_08)
		(L.L.bk_08_timer) 0 >
		{if}
			(L.L.engine_timer_last) 3600 >
			{if}
				(L.L.engine_timer_last) 3600 / s0 trunc s1 " 2" $IntToStrEnh
				l0 l1 - 100 * trunc "02" $IntToStrEnh $+
				(L.L.Time_BlinkOn)
				{if}
					" .  " $+
				{else}
					"    " $+
				{endif}
				(S.$.bk_08)
			{else}
				(L.L.engine_timer_last) 60 / trunc " 4" $IntToStrEnh
				"    " $+
				(S.$.bk_08)
			{endif}
		
		{else}
			(L.L.bk08_mode) 0 =
			{if}
				(L.L.engine_n) 1000 <
				{if}
					(L.L.engine_n) " 3" $IntToStrEnh "o    " $+ (S.$.bk_08)
				{else}
					(L.L.engine_n) $IntToStr 3 $SetLengthL "o.   " $+ (S.$.bk_08)
				{endif}
				(S.$.bk_08)
			{endif}
			
			(L.L.bk08_mode) 1 =
			{if}
				(L.L.elec_V_akum) s0 trunc s1 " 2" $IntToStrEnh
				l0 l1 - 10 * $IntToStr $+
				"v .  " $+
				(S.$.bk_08)
			{endif}
			
			(L.L.bk08_mode) 2 =
			{if}
				(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh
				l0 l1 - 60 * trunc "02" $IntToStrEnh $+
				(L.L.Time_BlinkOn)
				{if}
					" .  " $+
				{else}
					"    " $+
				{endif}
				(S.$.bk_08)
			{endif}
			
			(L.L.bk08_mode) 3 =
			{if}
				(L.L.Cabinair_Temp) 0 >=
				{if}
					(L.L.Cabinair_Temp) s0 trunc " 2" $IntToStrEnh
					l0 abs l0 abs trunc - 10 * " 1" $IntToStrEnh $+
					"c .  " $+
					(S.$.bk_08)
				{else}
					(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh
					"c    " $+
					(S.$.bk_08)
				{endif}
			{endif}
		{endif}
	{else}
		"        " (S.$.bk_08)
		0 (S.L.bk_08_timer)
	{endif}
{end}

{macro:windows_frame}

'	Запотевание

	(L.S.Weather_Temperature) 10 <
	(L.L.Rain_Window_Norm_Wetness) ||
	{if}
		(L.S.Weather_Temperature) 0 >
		{if}
			(L.L.Glass_pot) (L.S.Timegap) 0.05 * + 1 min (S.L.Glass_pot)
			(L.L.bt_obduv) (L.L.elec_busbar_main) &&
			{if}
				(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
				(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.001 * - 0 max (S.L.Glass_pot_front_noObduv)
			{else}
				(L.L.Glass_pot_front) (L.S.Timegap) 0.05 * + 1 min (S.L.Glass_pot_front)
				(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.05 * + 1 min (S.L.Glass_pot_front_noObduv)
			{endif}
		{endif}
	{else}
		(L.L.bt_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_pot_front) (L.S.Timegap) 0.05 * - 0 max (S.L.Glass_pot_front)
		{else}
			(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
		{endif}
		(L.L.Glass_pot) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot)
		(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front_noObduv)
	{endif}
	
'	Замерзание
	
	(L.S.Weather_Temperature) 0 <
	{if}
		(L.L.Glass_ice) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice)
		(L.L.Glass_pot) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot)
		(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
		(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front_noObduv)
		
		(L.L.bt_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.005 * - 0 max (S.L.Glass_ice_front_noObduv)
		{else}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice_front_noObduv)
		{endif}
	{else}
		(L.L.Glass_ice) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice)
		(L.L.bt_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.05 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.02 * - 0 max (S.L.Glass_ice_front_noObduv)
		{else}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front_noObduv)
		{endif}
	{endif}
	
	
'	Зеркала
	
	(L.S.PrecipType) 0 >
	{if}
		(L.L.Precip_mirror) (L.S.Timegap) (L.S.PrecipRate) 2 / * + 1 min (S.L.Precip_mirror)
	{else}
		(L.S.Weather_Temperature) 0 >
		{if}
			(L.L.Precip_mirror) (L.S.Timegap) 0.1 * - 0 max (S.L.Precip_mirror)
		{endif}
	{endif}
	
	(L.L.bt_mirror_obogrev) (L.L.elec_busbar_main) &&
	{if}
		(L.L.mirror_temp) (L.S.Timegap) 0.05 * + 0.5 min (S.L.mirror_temp)
		(L.L.Precip_mirror) (L.S.Timegap) (L.L.mirror_temp) * - 0 max (S.L.Precip_mirror)
	{else}
		(L.L.mirror_temp) (L.S.Timegap) 0.05 * - 0 max (S.L.mirror_temp)
	{endif}

	
{end}

















